<?php

/**
 * Link form base class.
 *
 * @method Link getObject() Returns the current form's model object
 *
 * @package    jobeet
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseLinkForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'           => new sfWidgetFormInputHidden(),
      'url'          => new sfWidgetFormInputText(),
      'size'         => new sfWidgetFormInputText(),
      'ordre'        => new sfWidgetFormInputText(),
      'nb_download'  => new sfWidgetFormInputText(),
      'is_active'    => new sfWidgetFormInputCheckbox(),
      'fily_id'      => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Fily'), 'add_empty' => false)),
      'format'       => new sfWidgetFormInputText(),
      'quality'      => new sfWidgetFormInputText(),
      'token_link'   => new sfWidgetFormInputText(),
      'dead'         => new sfWidgetFormInputText(),
      'is_verify'    => new sfWidgetFormInputCheckbox(),
      'user_link_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('sfGuardUser'), 'add_empty' => false)),
      'advert_link'  => new sfWidgetFormInputText(),
      'created_at'   => new sfWidgetFormDateTime(),
      'updated_at'   => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'           => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'url'          => new sfValidatorString(array('max_length' => 100)),
      'size'         => new sfValidatorNumber(),
      'ordre'        => new sfValidatorInteger(array('required' => false)),
      'nb_download'  => new sfValidatorInteger(array('required' => false)),
      'is_active'    => new sfValidatorBoolean(array('required' => false)),
      'fily_id'      => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Fily'))),
      'format'       => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'quality'      => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'token_link'   => new sfValidatorString(array('max_length' => 255)),
      'dead'         => new sfValidatorInteger(array('required' => false)),
      'is_verify'    => new sfValidatorBoolean(array('required' => false)),
      'user_link_id' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('sfGuardUser'))),
      'advert_link'  => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'created_at'   => new sfValidatorDateTime(),
      'updated_at'   => new sfValidatorDateTime(),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorAnd(array(
        new sfValidatorDoctrineUnique(array('model' => 'Link', 'column' => array('url'))),
        new sfValidatorDoctrineUnique(array('model' => 'Link', 'column' => array('token_link'))),
      ))
    );

    $this->widgetSchema->setNameFormat('link[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Link';
  }

}
